import request from './request'

// 订单相关的API

// 提交订单
export const submitOrderApi = (data) => {
    return request.post('/api/user/order/submit', data)
}


// 在@/api/orders中添加支付查询方法
export const queryPaymentResult = async (params) => {
    return request({
        url: '/payment/query',
        method: 'get',
        params
    })
}
export const createPayOrder = (data) => {
    return request.post('/api/pay/zfb', data)
}

// 获取订单详情
export const getOrderApi = (orderId) => {
    return request.get(`/api/user/order/${orderId}`)
}

// 取消订单
export const cancelOrderApi = (orderId) => {
    return request.post(`/api/user/order/cancel/${orderId}`)
}

// 历史订单查询
export const getHistoryOrdersApi = (page, pageSize, status = null) => {
    const params = { page, pageSize }
    if (status !== null) {
        params.status = status
    }
    return request.get('/api/user/order/historyOrders', { params })
}

// 条件订单查询
export const getConditionOrdersApi = (data) => {
    return request.post('/api/user/order/conditionOrders', data)
}

// 完成订单
export const completeOrderApi = (orderId) => {
    return request.post(`/api/user/order/complet/${orderId}`)
}